<template>
  <div class="commom-good-list" :class="[`col_2`]">
    <div class="title" v-if="!hideTitle">
      <div class="name"></div>
    </div>
    <div class="good-list">
      <div class="good-list__item" @click="handleToDetail(item.proid)" v-for="(item, index) in list" :key="`${item.proid}-${index}`">
        <div class="item__img">
          <img width="100%" :src="item.img1" />
        </div>
        <div class="item__info">
          <div class="title van-multi-ellipsis--l2">{{ item.proname }}</div>
          <div class="price">{{ item.originprice }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'CommonGoodList',
  props: {
    col: {
      type: Number,
      default: 2
    },
    hideTitle: Boolean,
    list: {
      type: Array,
      default: () => []
    }
  },
  data () {
    return {
      typeCol: this.col
    }
  },
  watch: {
    col (val) {
      this.typeCol = val
    }
  },
  methods: {
    handleChangeCol () {
      this.typeCol = this.typeCol === 1 ? 2 : 1
    },
    handleToDetail (id) {
      this.$router.push({ name: 'detail', params: { id } })
    }
  }
}
</script>
<style lang="scss" scoped>
.commom-good-list > .title {
  padding: 8px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .name {
    font-size: 16px;
  }
}
.commom-good-list.col_2 {
  /*  */
  .good-list {
    display: flex; flex-wrap: wrap;
    padding: 0 0.05rem;
    &__item {
      width: 1.825rem; padding: 0.05rem;
      .item__img {
        width: 100%;
        height: 1.825rem;
        background: #ccc;
        overflow: hidden;
      }
      .item__info {
        .title {
          font-weight: bolder;
          margin: 4px 0px;
          overflow: hidden;
        }
        .price {
          font-size: 16px;
          color: #ff4142;
          padding: 4px 0px;
        }
      }
    }
  }
}
</style>
